<?php

namespace App\Http\Controllers;

use App\Handlers\LunarCalendarHandler;
use Illuminate\Support\Carbon;

class MoFishController extends Controller
{
    public function show()
    {
        // 【摸鱼办】提醒您：2022年11月23日，农历壬寅[虎]年十月三十，周三，
        //大家上午好。工作再累，一定不要忘记休息哦！起身去茶水间，去厕所，去廊道走走活动一下身体，祝愿所有粉丝们，都能愉快的度过每一天…
        // 距离【周末】还有3天
        // 距离【元旦】还有38天
        // 距离【春节】还有59天
        // 距离【明年清明】还有132天
        // 距离【明年五一】还有158天
        // 距离【明年端午】还有210天
        // 距离【明年中秋】还有309天
        // 距离【明年国庆】还有311天
        // 距离【疫情开始】已有1077天

        // $now = Carbon::now()->toDateString(); // 2022-11-23

        // dump(Carbon::now()->dayOfWeek); // 3，代表这周的第三天
        $weeks = [
            1 => '周一',
            2 => '周二',
            3 => '周三',
            4 => '周四',
            5 => '周五',
            6 => '周六',
            7 => '周日',
        ];

        $lunar = new LunarCalendarHandler();
        $today = $lunar->convertSolarToLunar(date("Y"), date("m"), date("d"));
        $str = "【摸鱼办】提醒您：" . date("Y") . "年" . date("m") . "月" . date("d") . "日 " . $weeks[Carbon::now()->dayOfWeek] ."<br/>";
        $str .= "农历：" . $today[0] . "年" . $today[1] . $today[2] . "农历" . $today[3] . "年" . $today[4] . "月" . $today[5] . "日" . $today[6] . "年<br/>";
        $month = $lunar->getJieQi(date("Y"), date("m"), date("d"));//获取当前节气
        $str .= "节气：【" . $month["name2"] . "】<br/>";

        $str .= "大家上午好。工作再累，一定不要忘记休息哦！起身去茶水间，去厕所，去廊道走走活动一下身体，祝愿所有粉丝们，都能愉快的度过每一天…<br/>";


        if (Carbon::now()->isWeekend()) {
            $str .= "周末了就好好休息~ <br/>";
        } else {
            $endDaysToWeekend = 6 - Carbon::now()->dayOfWeek;
            $str .= "距离【周末】还有{$endDaysToWeekend}天<br/>";
        }

        $yuandan = (date("Y") + 1) . "-01-01";
        $d0 = Carbon::parse($yuandan)->diffInDays(Carbon::tomorrow());
        $str .= "距离【元旦】还有{$d0}天<br/>";

        $d1 = $lunar->getDaysBetweenNextLunar($today[0], $today[4], $today[5]);
        $str .= "距离【春节】还有{$d1}天<br/>";

        return view('mofish.show', compact('str'));
    }
}
